<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增项目')"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-project-add">
        <input id="leader" name="leader" type="hidden" th:value="*{leader}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">名称：</label>
            <div class="col-sm-8">
                <input name="name" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">负责人：</label>
            <div class="col-sm-8">
                <select id="leaderId" name="leaderId" class="form-control m-b" onchange="selectLeader(this)">
                    <option value="">--请选择--</option>
                    <option th:each="leaders:${leaders}" th:value="${leaders.userId}" th:text="${leaders.userName}"
                            th:disabled="${leaders.status == '1'}" th:phone="${leaders.phonenumber}"
                            th:email="${leaders.email}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">甲方：</label>
            <div class="col-sm-8">
                <input id="buyers" name="buyers" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">乙方：</label>
            <div class="col-sm-8">
                <input id="sellers" name="sellers" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">项目计划时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="startDate" class="form-control" placeholder="yyyy-MM-dd" type="text"
                           style="float: left;width: 48%;">
                    <div style="float: left;width: 4%;">到</div>
                    <input name="endDate" class="form-control" placeholder="yyyy-MM-dd" type="text"
                           style="float: left;width: 48%;">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea name="remark" class="form-control"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('project_status')}">
                    <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}"
                           th:checked="${dict.default}">
                    <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>
<script th:inline="javascript">
    var prefix = ctx + "system/project"
    $("#form-project-add").validate({
        focusCleanup: true
    });

    function selectLeader(e) {
        try {
            var opt = $(e.options[e.selectedIndex]);
            var leader = opt.text();
            if (!leader) {
                leader = ""
            }
            $('#leader').val(leader);
        } catch (e) {

        }
    }

    $("input[name='startDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='endDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-project-add').serialize());
        }
    }
</script>
</body>
</html>